package org.example.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class consoleOutput {

    private static final Logger log = LoggerFactory.getLogger(consoleOutput.class);

    public static void print(String TAG, String message) {
        int message_length = message.length();
        if (message_length < 10) {
            message_length = 20;
        }
        int tag_length = TAG.length();
        int arr = (message_length - tag_length) / 2;
        arr = arr < 0 ? Math.abs(arr) : arr;

        //标题栏
        StringBuilder Title_bar = new StringBuilder();
        Title_bar.append("-".repeat(Math.max(0, arr)))
                .append(TAG)
                .append("-".repeat(Math.max(0, arr)));
        System.out.println();
        System.out.println(Title_bar.toString());

        //内容
        StringBuilder content = new StringBuilder();
        content.append(TAG).append(": ").append(message);
        System.out.println(content);
        log.info("TAG: " + TAG + " MESSAGE: " + message);
        //结尾
        StringBuilder end = new StringBuilder();
        end.append("-".repeat(message_length));
        System.out.println(end);
        System.out.println();

    }
}
